package org.iblink.gui.swing;

import org.iblink.gui.swing.manager.AssetBrowserManager;
import org.iblink.gui.swing.manager.CategoryTreeManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Context for ;Blink application
 * 
 * @author tpares
 *
 */
public class IBlinkContext {
  
  /**
   * Context definition paths
   */
  private static final String[] CONTEXT_PATH = {"applicationContext.xml"};

  /**
   * Spring context
   */
  private static ApplicationContext context;
  
  private IBlinkContext() {
    // can not be instantiated
  }
  
  private static void initContext() {
    context = new ClassPathXmlApplicationContext(CONTEXT_PATH);
  }
  
  public static void initCategories() {
    if (context == null) {
      initContext();
    }
  }
  
  public static CategoryTreeManager getCategoryTreeManager() {
    return (CategoryTreeManager) context.getBean("categoryTreeManager");
  }
  
  public static AssetBrowserManager getAssetBrowserManager() {
    return (AssetBrowserManager) context.getBean("assetBrowserManager");
  }
}
